import {type Component, computed} from "vue";
import BooleanCell from "./simple/BooleanCell.vue";
import NumberCell from "./simple/NumberCell.vue";
import CharCell from "./char/CharCell.vue";
import ColorCell from "./char/ColorCell.vue";
import DefaultCell from "./simple/DefaultCell.vue";
import type {MetaField} from "../../types/cell.types";
import SelectCell from "./refer/SelectCell.vue";
import DateCell from "./date/DateCell.vue";
import TimeCell from "./date/TimeCell.vue";

export default function useCellComponents(field: MetaField) {
    const component: Component = getComponentByDomain(field.domain as string)

    return {component}
}

function getComponentByDomain(domain: String): Component {
    switch (domain) {
        case 'BooleanField':
            return BooleanCell
        case 'IntegerField':
        case 'FloatField':
            return NumberCell
        case 'TextField':
        case 'CharField':
            return CharCell
        case 'ManyToManyRel':
        case 'ManyToOneRel':
            return SelectCell
        case 'DateField':
        case 'DateTimeField':
            return DateCell
        case 'TimeField':
            return TimeCell
        default:
            return DefaultCell
    }
}